<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>消息队列设计：推模式 vs 拉模式</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .content-card {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }
        
        .content-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
        }
        
        .section-title {
            position: relative;
            padding-left: 20px;
        }
        
        .section-title::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 80%;
            background: linear-gradient(to bottom, #667eea, #764ba2);
            border-radius: 2px;
        }
        
        .feature-card {
            background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
            border: 1px solid rgba(0, 0, 0, 0.05);
            transition: all 0.3s ease;
        }
        
        .feature-card:hover {
            transform: translateY(-3px);
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
            background: linear-gradient(135deg, #ffffff 0%, #f5f7fa 100%);
        }
        
        .comparison-table {
            background: white;
            border-radius: 12px;
            overflow: hidden;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
        }
        
        .comparison-table th {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            font-weight: 600;
        }
        
        .comparison-table tr:nth-child(even) {
            background: #f8f9fa;
        }
        
        .icon-wrapper {
            width: 60px;
            height: 60px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 12px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            font-size: 24px;
            margin-bottom: 16px;
        }
        
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
        
        .highlight-text {
            background: linear-gradient(to right, #667eea, #764ba2);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            font-weight: 600;
        }
        
        .drop-cap {
            float: left;
            font-size: 4rem;
            line-height: 1;
            font-weight: 700;
            margin-right: 0.5rem;
            margin-top: -0.2rem;
            color: #667eea;
            font-family: 'Noto Serif SC', serif;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <div class="hero-gradient text-white py-20">
        <div class="container mx-auto px-6 text-center">
            <h1 class="text-5xl md:text-6xl font-bold mb-6 animate-pulse">
                消息队列设计的艺术
            </h1>
            <p class="text-2xl md:text-3xl mb-8 opacity-90">
                推模式 vs 拉模式：架构决策的关键
            </p>
            <div class="flex justify-center space-x-8 mt-12">
                <div class="text-center">
                    <i class="fas fa-paper-plane text-4xl mb-2"></i>
                    <p class="text-lg">推模式</p>
                </div>
                <div class="text-center">
                    <i class="fas fa-sync-alt text-4xl mb-2 animate-spin" style="animation-duration: 3s;"></i>
                    <p class="text-lg">VS</p>
                </div>
                <div class="text-center">
                    <i class="fas fa-magnet text-4xl mb-2"></i>
                    <p class="text-lg">拉模式</p>
                </div>
            </div>
        </div>
    </div>

    <!-- Main Content -->
    <div class="container mx-auto px-6 py-12">
        <!-- Introduction Card -->
        <div class="content-card rounded-2xl p-8 mb-12">
            <p class="text-lg leading-relaxed text-gray-700">
                <span class="drop-cap">消</span>息队列作为现代分布式系统的核心组件，其设计决策直接影响着系统的性能、可扩展性和可靠性。在众多设计选择中，推（Push）模式和拉（Pull）模式的选择尤为关键。这不仅是一个技术决策，更是对系统架构哲学的深刻思考。
            </p>
        </div>

        <!-- Message Queue Concept -->
        <div class="content-card rounded-2xl p-8 mb-12">
            <h2 class="section-title text-3xl font-bold mb-6 text-gray-800">
                <i class="fas fa-layer-group mr-3 text-purple-600"></i>
                消息队列的核心概念
            </h2>
            
            <div class="grid md:grid-cols-2 gap-6 mb-8">
                <div class="feature-card p-6 rounded-xl">
                    <div class="icon-wrapper">
                        <i class="fas fa-cogs"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">系统解耦</h3>
                    <p class="text-gray-600">通过消息队列，生产者和消费者可以独立演进，降低系统间的耦合度，提高整体架构的灵活性。</p>
                </div>
                
                <div class="feature-card p-6 rounded-xl">
                    <div class="icon-wrapper">
                        <i class="fas fa-bolt"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">异步处理</h3>
                    <p class="text-gray-600">将耗时操作异步化，提升系统响应速度，改善用户体验，让系统更加高效。</p>
                </div>
                
                <div class="feature-card p-6 rounded-xl">
                    <div class="icon-wrapper">
                        <i class="fas fa-chart-line"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">削峰填谷</h3>
                    <p class="text-gray-600">在流量高峰期缓冲请求，保护下游系统，确保服务的稳定性和可用性。</p>
                </div>
                
                <div class="feature-card p-6 rounded-xl">
                    <div class="icon-wrapper">
                        <i class="fas fa-shield-alt"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">可靠传输</h3>
                    <p class="text-gray-600">通过持久化和确认机制，确保消息不丢失，为关键业务提供可靠保障。</p>
                </div>
            </div>
        </div>

        <!-- Architecture Diagram -->
        <div class="content-card rounded-2xl p-8 mb-12">
            <h2 class="section-title text-3xl font-bold mb-6 text-gray-800">
                <i class="fas fa-project-diagram mr-3 text-purple-600"></i>
                架构模式对比
            </h2>
            
            <div class="mermaid">
                graph TB
                    subgraph "推模式 Push Model"
                        P1[生产者] -->|主动推送| Q1[消息队列]
                        Q1 -->|立即推送| C1[消费者1]
                        Q1 -->|立即推送| C2[消费者2]
                        style P1 fill:#667eea,stroke:#fff,color:#fff
                        style Q1 fill:#764ba2,stroke:#fff,color:#fff
                        style C1 fill:#f093fb,stroke:#333
                        style C2 fill:#f093fb,stroke:#333
                    end
                    
                    subgraph "拉模式 Pull Model"
                        P2[生产者] -->|发送消息| Q2[消息队列]
                        C3[消费者1] -->|主动拉取| Q2
                        C4[消费者2] -->|主动拉取| Q2
                        style P2 fill:#667eea,stroke:#fff,color:#fff
                        style Q2 fill:#764ba2,stroke:#fff,color:#fff
                        style C3 fill:#4facfe,stroke:#333
                        style C4 fill:#4facfe,stroke:#333
                    end
            </div>
        </div>

        <!-- Push Model Details -->
        <div class="content-card rounded-2xl p-8 mb-12">
            <h2 class="section-title text-3xl font-bold mb-6 text-gray-800">
                <i class="fas fa-paper-plane mr-3 text-purple-600"></i>
                推模式深度解析
            </h2>
            
            <div class="bg-gradient-to-r from-purple-50 to-pink-50 p-6 rounded-xl mb-6">
                <h3 class="text-xl font-semibold mb-3 text-purple-800">
                    <i class="fas fa-rocket mr-2"></i>核心优势
                </h3>
                <ul class="space-y-2 text-gray-700">
                    <li><i class="fas fa-check-circle text-green-500 mr-2"></i>极低延迟，消息实时送达</li>
                    <li><i class="fas fa-check-circle text-green-500 mr-2"></i>高效的消息传递，无轮询开销</li>
                    <li><i class="fas fa-check-circle text-green-500 mr-2"></i>消费者实现简单，只需监听即可</li>
                    <li><i class="fas fa-check-circle text-green-500 mr-2"></i>适合高频消息场景</li>
                </ul>
            </div>
            
            <div class="bg-gradient-to-r from-red-50 to-orange-50 p-6 rounded-xl">
                <h3 class="text-xl font-semibold mb-3 text-red-800">
                    <i class="fas fa-exclamation-triangle mr-2"></i>潜在挑战
                </h3>
                <ul class="space-y-2 text-gray-700">
                    <li><i class="fas fa-times-circle text-red-500 mr-2"></i>流量控制困难，易造成消费者过载</li>
                    <li><i class="fas fa-times-circle text-red-500 mr-2"></i>负载突变时系统稳定性差</li>
                    <li><i class="fas fa-times-circle text-red-500 mr-2"></i>需要复杂的背压机制</li>
                    <li><i class="fas fa-times-circle text-red-500 mr-2"></i>错误处理和重试机制复杂</li>
                </ul>
            </div>
        </div>

        <!-- Pull Model Details -->
        <div class="content-card rounded-2xl p-8 mb-12">
            <h2 class="section-title text-3xl font-bold mb-6 text-gray-800">
                <i class="fas fa-magnet mr-3 text-purple-600"></i>
                拉模式深度解析
            </h2>
            
            <div class="bg-gradient-to-r from-blue-50 to-cyan-50 p-6 rounded-xl mb-6">
                <h3 class="text-xl font-semibold mb-3 text-blue-800">
                    <i class="fas fa-star mr-2"></i>核心优势
                </h3>
                <ul class="space-y-2 text-gray-700">
                    <li><i class="fas fa-check-circle text-green-500 mr-2"></i>消费者自主控制消费速率</li>
                    <li><i class="fas fa-check-circle text-green-500 mr-2"></i>天然支持负载均衡</li>
                    <li><i class="fas fa-check-circle text-green-500 mr-2"></i>系统扩展性好，易于水平扩展</li>
                    <li><i class="fas fa-check-circle text-green-500 mr-2"></i>避免消费者过载问题</li>
                </ul>
            </div>
            
            <div class="bg-gradient-to-r from-yellow-50 to-amber-50 p-6 rounded-xl">
                <h3 class="text-xl font-semibold mb-3 text-yellow-800